package activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.example.administrator.ci_edit.R;

import java.util.Random;


public class MainActivity extends AppCompatActivity {

    private Button btn1;
    private Button btn2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn1=(Button) findViewById(R.id.select_poem_btn);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent();
                intent.setClass(MainActivity.this,PoemSelectActivity.class);
                Log.d("MainActivity","准备进行页面跳转了");
                MainActivity.this.startActivity(intent);
                Log.d("MainActivity","页面跳转了");
            }
        });

        btn2=(Button)findViewById(R.id.random_btn);
        btn2.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view){
                //生成一个随机数
                Random random=new Random();
                int randomNum=random.nextInt(98);
                randomNum=randomNum+1;//不允许生成为0的随机数Intent intent=new Intent();

                //传给界面PoemShowActivity
                Intent intent=new Intent();
                intent.setClass(MainActivity.this,PoemShowActivity.class);
                intent.putExtra("extra_mengid",randomNum);
                MainActivity.this.startActivity(intent);



            }
        });
    }
}
